using System;
using System.Globalization;

namespace RaisingStudio.SmallBasicCompiler
{
    [Serializable]
    public struct TokenInfo
    {
        private static TokenInfo _illegal = new TokenInfo
        {
            Line = 0,
            Column = 0,
            Token = Token.Illegal,
            TokenType = TokenType.Illegal
        };

        public static TokenInfo Illegal
        {
            get
            {
                return TokenInfo._illegal;
            }
        }

        public int Line
        {
            get;
            set;
        }
        public int Column
        {
            get;
            set;
        }
        public int EndColumn
        {
            get
            {
                if (this.Text != null)
                {
                    return this.Column + this.Text.Length;
                }
                return this.Column;
            }
        }
        public string NormalizedText
        {
            get
            {
                if (this.Text != null)
                {
                    return this.Text.ToLower(CultureInfo.CurrentUICulture);
                }
                return null;
            }
        }
        public string Text
        {
            get;
            set;
        }
        public Token Token
        {
            get;
            set;
        }
        public TokenType TokenType
        {
            get;
            set;
        }

        public override string ToString()
        {
            return string.Format("{0},{1}: {2}, {3}", new object[]
			{
				this.Line, 
				this.Column, 
				this.Text, 
				this.Token
			});
        }
    }
}
